﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace Cstudy.BLL
{
    public class Users
    {
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="user">用户实体</param>
        /// <returns></returns>
        public bool AddUser(MODEL.users user)
        {
            return new Cstudy.DAL.users().AddUser(user);
        }
        /// <summary>
        /// 修改用户
        /// </summary>
        /// <param name="user">用户实体</param>
        /// <returns></returns>
        public bool UpdateUser(MODEL.users user)
        {
            return new DAL.users().UpdateUser(user);
        }
        /// <summary>
        /// 验证用户名是否存在
        /// </summary>
        /// <param name="name">用户名</param>
        /// <returns>是否存在</returns>
        public bool ExistUserName(string name)
        {
            return new DAL.users().ExistUserName(name);
        }
        /// <summary>
        /// 验证邮箱是否存在
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public bool ExitsEmail(string email)
        {
            return new DAL.users().ExistEmail(email);
        }

        public DataSet UserLogin(MODEL.users user)
        {
            return new DAL.users().UserLogin(user);
        }
        /// <summary>
        /// 通过ID查询用户
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public DataSet SelectUserByID(int id)
        {
            return new DAL.users().SelectUserByID(id);
        }
        /// <summary>
        /// 通过用户名查询用户
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public DataSet SelectUserByName(string name)
        {
            return new DAL.users().SelectUserByName(name);
        }
        /// <summary>
        /// 分页查询用户
        /// </summary>
        /// <param name="currentPage">当前页数</param>
        /// <param name="pagesize">分页大小</param>
        /// <param name="num">返回参数</param>
        /// <param name="returnstring">返回参数名</param>
        /// <returns></returns>
        public DataSet SelectUser(int currentPage, int pagesize, out int num, string returnstring)
        {
            return new DAL.users().SelectUser(currentPage, pagesize, out num, "@count");
        }
    }
}
